package com.xinqi.modules.course.content.mapper;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.xinqi.common.mybatis.data.repo.SuperMapper;
import com.xinqi.modules.course.content.domain.CourseContentEntity;
import com.xinqi.modules.course.content.dto.req.ContentMonthDayQueryDTO;
import com.xinqi.modules.course.content.dto.req.CourseContentQueryByChapterDTO;
import com.xinqi.modules.course.content.dto.rsp.CourseRepeatContentResult;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.util.List;
import java.util.Map;

/**
 * 课程内容表数据层
 *
 * @author: system
 * @date: 2023/03/08
 */
@Mapper
public interface CourseContentMapper extends SuperMapper<CourseContentEntity> {

    IPage<Map<String, Object>> selectYearMonth(@Param("page") Page<?> page, @Param("classId") Long classId);

    /**
     * 课程汇总年月日周查询
     */
    IPage<Map<String, Object>> selectYearMonthDay(@Param("page") Page<?> page, @Param("classId") Long classId, @Param("contentTypes") List<Integer> contentTypes);

    List<Map<String, Object>> selectMonthDay(@Param("queryParam") ContentMonthDayQueryDTO queryParam);

    List<CourseRepeatContentResult> selectTeacherAllDay(ContentMonthDayQueryDTO queryParam);

    List<CourseRepeatContentResult> selectStudentAllDay(ContentMonthDayQueryDTO queryParam);

    List<CourseContentEntity> selectTeacherContentByChapterId(CourseContentQueryByChapterDTO query);

    List<CourseContentEntity> selectStudentContentByChapterId(CourseContentQueryByChapterDTO query);

    int updateStatus(@Param("contentId") Long contentId, @Param("status") Integer status);

    void clearChapter(@Param("idList") List<Long> idList);

    int deleteByCourseContent(@Param("contentIds") List<Long> contentIds, @Param("type") Integer type);

    Boolean updateCourseContentByType(List<CourseContentEntity> list);

    Boolean updateCourseContentTotalByType(List<CourseContentEntity> list);

    void removeCourseContentBatchByContentId(@Param("idList") List<Long> idList);

    int deleteOutById(@Param("id") Long id);

    CourseContentEntity selectByContent(@Param("contentId") Long contentId, @Param("contentType") Integer contentType);

    int updateStatusContentType(@Param("contentId") Long contentId, @Param("status") Integer status, @Param("contentType") Integer contentType);

    int updateExamTiming();

    int updateExamStart();

    int updateExamStatusByContentIds(@Param("contentIds") List<Long> contentIds, @Param("status") Integer status, @Param("type") Integer type);

    int updateEndExam(@Param("contentId") Long contentId);
}
